package com.gxkj.bijia.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author sqyc
 */

public enum Platforms {

    JD(1,  "京东"),TAOBAO(2,  "淘宝"),TMALL(3,  "天猫");
    public int value;
    public String i18n;


    Platforms(int value, String i18n) {
        this.value = value;
        this.i18n = i18n;
    }

    public static Map<String ,String> valeu2I18nMap = new HashMap<>();
    public static Map<String ,Integer> i18n2valueMap = new HashMap<>();
    public static Map<String ,Platforms> i18n2Map = new HashMap<>();

    public String getI18n() {
        return this.i18n;
    }
    public int getValue() {
        return this.value;
    }

    public String getValueStr() {
        return String.valueOf(this.value);
    }
    // 普通方法
    public static String getDis(int value) {
        if(valeu2I18nMap.get(""+value) == null){
            for (Platforms status : Platforms.values()) {
                if (status.getValue() == value) {
                    valeu2I18nMap.put(""+value,status.getI18n());
                    break;
                }
            }
        }

        return valeu2I18nMap.get(""+value);
    }

    public static int getValueByI18n(String i18n){
        if(i18n2valueMap.get(i18n) == null){
            for (Platforms status : Platforms.values()) {
                if (status.getI18n().equals(i18n)) {
                    i18n2valueMap.put(i18n,status.getValue());

                }
            }
        }

        return i18n2valueMap.get(i18n);
    }

    public static Platforms getPlatforms(int value) {
        if(i18n2Map.get(""+value) == null){
            for (Platforms status : Platforms.values()) {
                if (status.getValue() == value) {
                    i18n2Map.put(""+value,status);
                    break;
                }
            }
        }

        return i18n2Map.get(""+value);
    }

}
